<?php
		
	/* SVN FILE: $Id: uploads.rename.php 8 2011-03-13 08:32:38Z michele.andreoletti@gmail.com $ */
	
	/**
	 * Project Name : arcadia
	 *
	 * @author $Author: michele.andreoletti@gmail.com $
	 * @version $Revision: 8 $
	 * @lastrevision $Date: 2011-03-13 08:32:38 +0000 (Sun, 13 Mar 2011) $
	 * @filesource $URL: http://arcadia.googlecode.com/svn/trunk/include/uploads.rename.php $
	 */
	
	date_default_timezone_set('Europe/Rome');
	
	if(isset($_POST['sAPP']) && !empty($_POST['sAPP'])) {
		$sAPP = $_POST['sAPP'];	

	} else {
		require_once "./const.inc.php";
		require_once "./functions.php";
		// require_once "./auth.inc.php";
		require_once "./conn.inc.php";
		
		fnUpdateLog('APP NOT DEFINED', 0, '', 'E');
		echo 'app-not-defined';
		die();
	
	}

	require_once "../$sAPP/include/const.inc.php";
	require_once "../$sAPP/include/functions.php";
	require_once "./auth.inc.php";
	require_once "./conn.inc.php";
	
	fnGetValueFromPOST(array('sDescription','iUpload'));
	
	$sQuery = "UPDATE `uploads` SET `sDescription` = '".$sDescription."' WHERE `id` = '".$iUpload."'";
	$rResult = custom_mysql_query($sQuery);
	
	$sQuery = "SELECT * FROM `uploads` WHERE `id` = '".$iUpload."'";
	$rResult = custom_mysql_query($sQuery);
	
	if (mysql_num_rows($rResult) == 1) {
		$aRow = mysql_fetch_assoc($rResult);
		if (!empty($aRow['sDescription'])) {
			fnUpdateLog("FILE RENAMED [".$aRow['sName']."]", $aRow['iView'], $aRow['sSelectFrom'], 'I');
			echo $aRow['sDescription'];
		} else {
			echo $aRow['sName'];
		}
	} else {
		fnUpdateLog("FILE NOT FOUND", 0, '', 'I');
		echo '';
	}
	
	die();
?>